package smashedapples.data.oql
{
	
	import smashedapples.core.NonVisualComponent;
	
	public class Query extends NonVisualComponent
	{
		public function Query(){}
		
		[Bindable("resultChanged")] public var result:XML;
		
		
		private var _where:String = "";
		
		[Inspectable(category="Data", defaultValue="undefined")]
		public function get where():String
		{
			return _where;
		}
		
		public function set where( value:String ):void
		{
			_where = value;
			addPropertyChanged( "where" );
		}
		
		public function onCommitWhere():void
		{
			trace("onCommitWhere");
		}
		
				
		public var root:String = "result";
		
		private var _dataProvider:Object;
		
		[Bindable]
		public function get dataProvider():Object
		{
			return _dataProvider;	
		}
		public function set dataProvider( value:Object ):void
		{
			_dataProvider = value;
			addPropertyChanged( "dataProvider" );
		}
		
		public function onCommitDataProvider():void
		{
			convertObjectToXML( this.dataProvider );
			
		}
	
		private function convertObjectToXML( object:Object ):void
		{
			var xml:XML = <{result} />;
	
			for( var property:String in object )
			{
				trace( property );
			}
			
			trace( xml.toXMLString() );
		}
		
		/* private function addXMLAttributes():XML
		{
			
		} */
		
			
		
		
		
		
		
		
		
		
		
		

	}
}